package com.carbon.assets.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.carbon.assets.entity.CarbonCreditAssets;
import com.carbon.assets.entity.CarbonMetaregistry;
import com.carbon.assets.mapper.*;
import com.carbon.assets.service.CarbonCreditAssetsService;
import com.carbon.assets.vo.CarbonCreditAssetsQueryVo;

import com.carbon.assets.vo.SelectorVo;

import com.carbon.common.service.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.metadata.IPage;

import java.math.BigDecimal;

import java.util.List;


/**
 * <p>
 * 碳信用资产 服务实现类
 * </p>
 *
 * @author Li Jun
 * @since 2022-04-24
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class CarbonCreditAssetsServiceImpl extends BaseServiceImpl<CarbonCreditAssetsMapper, CarbonCreditAssets> implements CarbonCreditAssetsService {
        @Resource CarbonCreditAssetsMapper carbonCreditAssetsMapper;

    @Override
    public List<CarbonCreditAssetsQueryVo> queryJoinCreditAssets(String tenantId) {
        List<CarbonCreditAssetsQueryVo> carbonCreditAssetsQueryVos = carbonCreditAssetsMapper.selectJoin(tenantId);
        return carbonCreditAssetsQueryVos;
    }

    @Override
    public IPage<CarbonMetaregistry> queryProjectList(Page<CarbonMetaregistry> pagination, String projectName, Long tenantId) {
        return carbonCreditAssetsMapper.queryProjectList(pagination, projectName, tenantId);
    }

    @Override
    public CarbonCreditAssets getByCarbonProjectId(Long projectId) {
        return carbonCreditAssetsMapper.getByCarbonProjectId(projectId);
    }

    @Override
    public void updateAmount(Long projectId, BigDecimal tradeQuantity) {
        carbonCreditAssetsMapper.updateAmount(projectId, tradeQuantity);
    }
    public CarbonCreditAssetsQueryVo queryJoinOneCreditAssets(String id, String tenantId) {
        CarbonCreditAssetsQueryVo carbonCreditAssetsQueryVo = carbonCreditAssetsMapper.selectOneJoin(id,tenantId);
        return carbonCreditAssetsQueryVo;
    }

    @Override
    public Page<CarbonCreditAssetsQueryVo> selectBySelector(Page<CarbonCreditAssetsQueryVo> page, SelectorVo selectorVo) {
        return carbonCreditAssetsMapper.selectBySelector(page, selectorVo);
    }


}
